import { defineStore } from 'pinia';

const nocache = defineStore({
  id: 'nocache',
  state: () => {
    return {
      hitBottom: 0,
      loading: false,
      openLoginCount: 0, // 触发登录
      openSignupCount: 0, // 触发登录
      openTaskCount: 0, // 触发任务中心
      openWalletCount: 0, // 触发任务中心
      menuType: 'normal', //
      isOpenHeader: true,
      socket: <any>null,
      jackPot: [],
      hideFooterBar: false,
      lotteryActive: 0, // 转盘那里active
      activity: {}, // 转盘那里activity
    };
  },
  // 等同于vuex的getter
  getters: {
    getHitBottom: (state) => state.hitBottom,
    getLoading: (state) => state.loading,
    getOpenLogin: (state) => state.openLoginCount,
    getOpenSignup: (state) => state.openSignupCount,
    getMenuType: (state) => state.menuType,
    getOpenTask: (state) => state.openTaskCount,
    getOpenWallet: (state) => state.openWalletCount,
    getIsOpenHeader: (state) => state.isOpenHeader,
    getSocket: (state) => state.socket,
    getJackPot: (state) => state.jackPot,
    getHideFooterBar: (state) => state.hideFooterBar,
    getLotteryActive: (state) => state.lotteryActive,
    getActivity: (state) => state.activity,

  },
  actions: {
    setHitBottom() {
      this.hitBottom += 1;
    },
    setLoading(toggle: boolean) {
      this.loading = toggle;
    },
    openLogin() {
      this.openLoginCount += 1;
    },
    openSignup() {
      this.openSignupCount += 1;
    },
    setMenuType(type: string) {
      this.menuType = type;
    },
    openTask() {
      this.openTaskCount += 1;
    },
    openWallet() {
      this.openWalletCount += 1;
    },
    setIsOpenHeader(toggle: boolean) {
      this.isOpenHeader = toggle;
    },
    setSocket(socket: any) {
      this.socket = socket;
    },
    setJackPot(jackPot: any){
      this.jackPot = jackPot;
    },
    setHideFooterBar(toggle: boolean) {
      this.hideFooterBar = toggle;
    },
    setLotteryActive(number: number) {
      this.lotteryActive = number;
    },
    setActivity(activity: any) {
      this.activity = activity;
    },

  },
});

export default nocache;
